package com.example.redis.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author : xh.Z
 * @email : fisherman0510@163.com
 * @Date : 2021/1/14 11:11
 * @description :
 */
@Configuration
public class RedissonConfig {


    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useMasterSlaveServers()
                //可以用"rediss://"来启用SSL连接
                .addSlaveAddress("redis://192.168.101.140:6381", "redis://192.168.101.140:6382")
                .addSlaveAddress("redis://192.168.101.140:6383")
                .setMasterAddress("redis://192.168.101.140:6384")
                .setMasterAddress("redis://192.168.101.140:6385")
                .setMasterAddress("redis://192.168.101.140:6386");

        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }
}
